﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BIS.Portal.Core.Global;

namespace BIS.Portal.Modules.CMS.Adm.ModuleUtility
{
    public class CmsPortalContextValue
    {
        public static string CurrentUpdateUser
        {
            get
            {
                if (PortalContext.CurrentUser == null)
                    return "";

                return PortalContext.CurrentUser.UserName;
            }
        }

        public static int CurrentLanguageInUseId
        {
            get
            {
                try
                {
                    return PortalContext.LanguageInUseId;
                }
                catch (Exception exception)
                {
                    Console.Write(exception);
                }

                return 1;
            }
        }

        public static string GetLink(string ruleName, string pageAlias)
        {
            try
            {
                if (string.IsNullOrEmpty(pageAlias))
                    return WebHelpers.GetLink(ruleName);
                return WebHelpers.GetLink(ruleName, pageAlias);
            }
            catch (Exception)
            {
                return "";
            }
        }

        public static string GetLink(string ruleName, string pageAlias, string[] query, string[] value)
        {
            try
            {
                if (string.IsNullOrEmpty(pageAlias))
                    return WebHelpers.GetLink(ruleName, query, value);
                return WebHelpers.GetLink(ruleName, pageAlias, query, value);
            }
            catch (Exception)
            {
                return "";
            }

        }
    }
}